package com.qf.controller;

import com.qf.pojo.reqVo.OrderReq;
import com.qf.pojo.respVo.BaseResp;
import com.qf.service.AlipayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    AlipayService alipayService;

    @RequestMapping("/alipay")
    public BaseResp alipay(@RequestBody OrderReq orderReq){
        return alipayService.pay(orderReq.getOrderid());
    }

    /**
     * 支付宝的回调接口，在该接口中，我们需要更改当前订单的支付状态
     * @param request
     */
    @RequestMapping("/callback")
    public void callBack(HttpServletRequest request){
        alipayService.callBack(request);
    }
}
